package infostroy.bookagolf.common.helpers;

import com.academysmart.bookagolf.i18n.Messages;
import com.academysmart.bookagolf.logging.Loggers;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateTimeHelper {

    public static final String MONDAY =  Messages.PricesViewListGame_Mon;
    public static final String TUESDAY =  Messages.PricesViewListGame_Tue;
    public static final String WEDNESDAY = Messages.PricesViewListGame_Wed;
    public static final String THURSDAY = Messages.PricesViewListGame_Thu;
    public static final String FRIDAY = Messages.PricesViewListGame_Fri;
    public static final String SATURDAY = Messages.PricesViewListGame_Sat;
    public static final String SUNDAY = Messages.PricesViewListGame_Sun;

	public static final String DATE_TYPE_APPLICATION = "dd MMMM yyyy,HH:mm";

	public static final String DATE_TYPE_REST = "yyyy-MM-dd";

	public static final String DATE_TYPE_REST_WITH_TZ = "yyyy-MM-dd'T'HH:mm:ss'Z'";

	public static String dateToString(Date date, String pattern) {
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		return format.format(date);
	}

	public static Date stringToDate(String date, String pattern)
			throws ParseException {
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		return format.parse(date);
	}

	public static String convertToAppDate(String date, String pattern) {
		try {
			SimpleDateFormat format = new SimpleDateFormat(pattern);
			Date d = format.parse(date);
			format.applyPattern(DATE_TYPE_APPLICATION);
			return format.format(d);
		} catch (ParseException e) {
			Loggers.FILE_LOGGER.info(e.getMessage());
		}
		return "";
	}

}
